using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;

public class BuildScript
{
    public BuildTarget buildTarget;

    public string buildPath;

    public virtual string fileExtensions
    {
        get;
    }

    public void StartBuild(string buildPath)
    {
        this.buildPath = buildPath;

        CollectAssetBuild();

        GenVersion();
    }

    protected virtual void GenVersion()
    {
        
    }
    
    protected virtual void CollectAssetBuild()
    {
        
    }
    
    private static string GetPlatformForAssetBundles(BuildTarget target)
    {
        // ReSharper disable once SwitchStatementMissingSomeCases
        switch (target)
        {
            case BuildTarget.Android:
                return "Android";
            case BuildTarget.iOS:
                return "iOS";
            case BuildTarget.WebGL:
                return "WebGL";
            case BuildTarget.StandaloneWindows:
            case BuildTarget.StandaloneWindows64:
                return "Windows";
            case BuildTarget.StandaloneOSX:
                return "OSX";
            default:
                return null;
        }
    }

    public virtual void GenBundle()
    {
        
    }
    public string CreateAssetBundleDirectory()
    {
        // Choose the output path according to the build target.
        Path.Combine(Application.dataPath, GameUtility.EditorOutPutPath);
        var outputPath = Path.Combine(GameUtility.EditorOutPutPath, GetPlatformForAssetBundles(buildTarget));
        // if (!Directory.Exists(outputPath))
            // Directory.CreateDirectory(outputPath);

        return outputPath;
    }
}
